<a href="http://github.com/angular/angular.js/tree/v1.2.9/src/ng/anchorScroll.js#L3" class="view-source btn btn-action"><i class="icon-zoom-in"> </i> View source</a><a href="http://github.com/angular/angular.js/edit/master/src/ng/anchorScroll.js" class="improve-docs btn btn-primary"><i class="icon-edit"> </i> Improve this doc</a><h1><code ng:non-bindable="">$anchorScroll</code>
<div><span class="hint">service in module <code ng:non-bindable="">ng</code>
</span>
</div>
</h1>
<div><h2 id="description">Description</h2>
<div class="description"><div class="ng-anchorscroll-page"><p>When called, it checks current value of <code>$location.hash()</code> and scroll to related element,
according to rules specified in
<a href="http://dev.w3.org/html5/spec/Overview.html#the-indicated-part-of-the-document">Html5 spec</a>.</p>
<p>It also watches the <code>$location.hash()</code> and scrolls whenever it changes to match any anchor.
This can be disabled by calling <code>$anchorScrollProvider.disableAutoScrolling()</code>.</p>
</div></div>
<h2 id="dependencies">Dependencies</h2>
<ul class="dependencies"><li><code ng:non-bindable=""><a href="api/ng.$window">$window</a></code>
</li>
<li><code ng:non-bindable=""><a href="api/ng.$location">$location</a></code>
</li>
<li><code ng:non-bindable=""><a href="api/ng.$rootScope">$rootScope</a></code>
</li>
</ul>
<h2 id="usage">Usage</h2>
<div class="usage"><pre class="prettyprint linenums">$anchorScroll();</pre>
</div>
<h2 id="example">Example</h2>
<div class="example"><div class="ng-anchorscroll-page"><h4 id="example_source">Source</h4>
<div source-edit="" source-edit-deps="angular.js script.js" source-edit-html="index.html-2" source-edit-css="style.css" source-edit-js="script.js-3" source-edit-json="" source-edit-unit="" source-edit-scenario="" source-edit-protractor=""></div>
<div class="tabbable"><div class="tab-pane" title="index.html">
<pre class="prettyprint linenums" ng-set-text="index.html-2" ng-html-wrap=" angular.js script.js"></pre>
<script type="text/ng-template" id="index.html-2">
  <div id="scrollArea" ng-controller="ScrollCtrl">
    <a ng-click="gotoBottom()">Go to bottom</a>
    <a id="bottom"></a> You're at the bottom!
  </div>
</script>
</div>
<div class="tab-pane" title="style.css">
<pre class="prettyprint linenums" ng-set-text="style.css"></pre>
<style type="text/css" id="style.css">
  #scrollArea {
    height: 350px;
    overflow: auto;
  }

  #bottom {
    display: block;
    margin-top: 2000px;
  }
</style>
</div>
<div class="tab-pane" title="script.js">
<pre class="prettyprint linenums" ng-set-text="script.js-3"></pre>
<script type="text/ng-template" id="script.js-3">
  function ScrollCtrl($scope, $location, $anchorScroll) {
    $scope.gotoBottom = function (){
      // set the location.hash to the id of
      // the element you wish to scroll to.
      $location.hash('bottom');
      
      // call $anchorScroll()
      $anchorScroll();
    }
  }
</script>
</div>
</div><h4 id="example_demo">Demo</h4>
<div class="well doc-example-live animate-container" ng-embed-app="" ng-set-html="index.html-2" ng-eval-javascript="script.js-3"></div>
</div></div>
</div>
